package com.xlh.virtualization.constant;

/**
 * 集群角色枚举
 *
 * @author cheer
 */
public enum ContainerRoleEnum {

    SINGLE(0, "单节点"),
    MASTER(1, "主节点"),
    SLAVE(2, "从节点");

    private Integer code;
    private String message;

    ContainerRoleEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static ContainerRoleEnum forCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (ContainerRoleEnum containerRoleEnum : ContainerRoleEnum.values()) {
            if (containerRoleEnum.code.equals(code)) {
                return containerRoleEnum;
            }
        }
        return null;
    }
}
